<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */
use process\Http;
use support\Log;
use support\Request;
global $argv;

return [
    'webman' => [
        'handler' => Http::class, // 进程处理类
        'listen' =>  'http://0.0.0.0:' . env('PORT', 7777),  // 监听地址
        'transport' => 'tcp', // 传输层协议
        'count' => cpu_count() * 4,
        'name' => 'webman', // 进程名
        'user' => '',// 用户
        'group' => '', // 用户组
        'reusePort' => false, // 是否开启端口复用
        'eventLoop' => '', // 默认为空自动选择Select或者Event，不开启协程
        'context' => [], //ssl等配置
        'constructor' => [
            'requestClass' => Request::class, // 可以自定义请求类
            'logger' => Log::channel('default'),// 日志实例
            'appPath' => app_path(),  // app目录位置
            'publicPath' => public_path() // public目录位置
        ]
    ],
    // 监控进程，用于检测文件更新自动加载和内存泄漏
    'monitor' => [
        'handler' => process\Monitor::class,
        'reloadable' => false,  // 当前进程不执行reload
        'constructor' => [
            // 监听的目录，不要过多，会导致检测变慢
            'monitorDir' => array_merge([
                app_path(),
                config_path(),
                base_path() . '/process',
                base_path() . '/support',
                base_path() . '/resource',
                base_path() . '/.env',
            ],
                glob(base_path() . '/plugin/*/app'),
                glob(base_path() . '/plugin/*/config'),
                glob(base_path() . '/plugin/*/api'),
                glob(base_path() . '/plugin/*/model'),
                glob(base_path() . '/plugin/*/service')
            ),
            // / 监听这些后缀文件的更新
            'monitorExtensions' => [
                'php', 'html', 'htm', 'env'
            ],
            // 其它选项
            'options' => [
                // 是否开启文件监控，仅在linux下有效，默认守护进程模式不开启文件监控
                'enable_file_monitor' => !in_array('-d', $argv) && DIRECTORY_SEPARATOR === '/',
                // 是否开启内存监控，仅支持在linux下开启
                'enable_memory_monitor' => DIRECTORY_SEPARATOR === '/',
            ]
        ]
    ],
    // 定时任务进程
    'task' => [
        'handler'  => \process\task\CleanLog::class
    ],

];
